﻿@model IEnumerable<Scap.Info.ScapDepartment>
@*model PagedList.PagedList<Scap.Info.ScapDepartment>*@

<div>
    <div>
        @{
            string szNomDepto = "";
            szNomDepto = string.Format("NomDepto_{0}", ViewBag.DepartamentoPadreNombre);

        }
        <div id="optioncallId" style="display: block">@ViewBag.TipoDepartamento</div>
        <table style="width: 100%">
            <tr>
                <td>
                    <span class="optionBuscarDeptoArea">
                        @Html.ActionLink("Seleccionar", "Select", new { id = ViewBag.DepartamentoPadreId }) |
                    </span>
                    @*<a href="#">Seleccionar</a> |*@

                    @if (ViewBag.DepartamentoRegresa != null)
                    {
                        @Ajax.ActionLink("Regresar", "BuscarDepartamento", "tabsEmpleado", new { departamentId = ViewBag.DepartamentoRegresa }, new AjaxOptions
                        {
                            UpdateTargetId = "departamentoDialog",
                            LoadingElementId = "waitDocumentiImage",
                            OnSuccess = "AjaxDocumentoSuccess",
                            OnFailure = "AjaxFailure"
                        }, null)                        
                    }
                </td>
                <td>@ViewBag.DepartamentoPadre&nbsp;(<span id="@szNomDepto">@ViewBag.DepartamentoPadreNombre</span>)</td>
            </tr>
        </table>
        <table style="width: 100%">
            <tr>
                <th></th>
                <th>
                    @Html.DisplayNameFor(model => model.Name)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Description)
                </th>
                @*<th>
            @Html.DisplayNameFor(model => model.TypeId)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AddressId)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ParentDepartmentId)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.CompanyId)
        </th>*@
            </tr>

            @foreach (var item in Model)
            {
                szNomDepto = string.Format("NomDepto_{0}", item.Name);

                <tr>
                    <td>
                        <span class="optionBuscarDeptoArea">
                            @Html.ActionLink("Seleccionar", "Select", new { id = item.Id }) |
                        </span>
                        @*<a href="#">Seleccionar</a> |*@
                        @Ajax.ActionLink("Detalles", "BuscarDepartamento", "tabsEmpleado", new { departamentId = item.Name }, new AjaxOptions
                        {
                            UpdateTargetId = "departamentoDialog",
                            LoadingElementId = "waitDocumentiImage",
                            OnSuccess = "AjaxDocumentoSuccess",
                            OnFailure = "AjaxFailure"
                        }, null)

                    </td>
                    <td id="@szNomDepto">
                        @Html.DisplayFor(modelItem => item.Name)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Description)
                    </td>
                    @*<td>
            @Html.DisplayFor(modelItem => item.TypeId)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.AddressId)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ParentDepartmentId)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CompanyId)
        </td>*@
                </tr>
            }

            <tr>
                <td colspan="3">
                    <table border="0" cellpadding="0" cellspacing="0" style="width: 95%">
                        <tr>
                            <td>
                                <div class="viosLink">
                                    Page @(ViewBag.PageCount < ViewBag.PageNumber ? 0 : ViewBag.PageNumber)
                                    of @ViewBag.PageCount
                                    &nbsp;
                                @if (ViewBag.HasPreviousPage)
                                {
                                    @Html.ActionLink("First", "Index", new { page = 1, sortOrder = ViewBag.CurrentSort })
                                    @Html.Raw("&nbsp;");
                                    @Html.ActionLink("Prev", "Index", new { page = ViewBag.PageNumber - 1, sortOrder = ViewBag.CurrentSort })
                                }
                                else
                                {
@*:<<*@
                                    @Html.Raw("&nbsp;");
@*:Prev*@
                                }
                                    &nbsp;
                                @if (ViewBag.HasNextPage)
                                {
                                    @Html.ActionLink("Next", "Index", new { page = ViewBag.PageNumber + 1, sortOrder = ViewBag.CurrentSort })
                                    @Html.Raw("&nbsp;");
                                    @Html.ActionLink("Last", "Index", new { page = ViewBag.PageCount, sortOrder = ViewBag.CurrentSort })
                                }
                                else
                                {
@*:Next*@
                                    @Html.Raw("&nbsp;")
@*:>>*@
                                }
                                </div>
                            </td>
                            <td style="display: none">
                                @Html.ActionLink("Back", "Index")
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>

        </table>
    </div>
    <div>
        <input id="btCloseDepto" type="button" value="Cerrar" />
    </div>
</div>

